﻿
@{
    ViewBag.Title = "MonthReportIndex";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<div class="rows">
    <div class="panel panel-default">
        <table class="form">
            <tr>
                <th class="formTitle">年份：</th>
                <td class="formValue">
                    <select id="year" name="year">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <th class="formTitle">月份：</th>
                <td class="formValue">
                    <select id="month" name="month">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <th class="formTitle">治疗师：</th>
                <td class="formValue">
                    <input id="zls" name="zls" type="text" class="form-control" />
                    <input id="zlsId" name="zlsId" type="text" class="form-control" style="display:none;" />
                    <input id="zlsGh" name="zlsGh" type="text" class="form-control" style="display:none;" />
                </td>
                <th class="formTitle"></th>
                <td class="formValue" style="padding-left:20px;">
                    <input type="button" id="btn_search" onclick="submit();" class="btn btn-primary btn-md" value="查询" style="width:55px" />
                </td>
                <th></th>
                <td></td>
            </tr>
        </table>
    </div>
</div>

<div class="ui-layout" id="layout" style="height:100%;width:100%;">
    <iframe class="ui-layout-center" style="width:100%;" id="iframerightiframerightiframerightttt" name="iframerightiframerightiframerightttt"
            scrolling="auto" allowtransparency="true" frameborder="0"></iframe>
</div>

<script type="text/javascript">
    var reportServerHOST = '@(ViewBag.ReportServerHOST)';
    var orgId = '@(ViewBag.OrgId)';
    var isHospAdministrator = '@(ViewBag.IsHospAdministrator)';
    var curUserCode = '@(ViewBag.CurUserCode)';

    var uri = 'ReportServer/Pages/ReportViewer.aspx?%2fHIS.Report.1%2f%E6%B2%BB%E7%96%97%E5%B8%88%E5%B7%A5%E4%BD%9C%E7%BB%9F%E8%AE%A1&rs:Command=Render';

    function submit() {

        if ($('#year').val().length == 0) {
            $.modalAlert("缺少年份", "error");
            return;
        }
        if ($('#month').val().length == 0) {
            $.modalAlert("缺少月份", "error");
            return;
        }

        var url = getUrl();

        url += "&year=" + $('#year').val();
        url += "&month=" + $('#month').val();
        url += "&ysgh=" + $('#zlsGh').val();

        setTimeout("$.loading(true, '正在请求报表页面...');", 10);
        $("#iframerightiframerightiframerightttt").attr('src', url);
    }

    $("#iframerightiframerightiframerightttt").load(function () {
        $.loading(false);
    });

    $(function () {
        var h = $(window).height() - 55
        $('#layout iframe').css('height', h);

        init();

        setTimeout(function () { submit(); }, 100);
    });

    function init() {
        //治疗师选择
        $('#zls').click(function () {
            var initIdSelected = $('#zlsId').val();
            $.modalOpen({
                id: "StaffCorrelation",
                title: "选择治疗师",
                url: "/SystemManage/SysStaff/Selector?single=true&isContansChildOrg=false&callbackType=json&dutyCode=RehabDoctor&initIdSelected=" + initIdSelected,
                showleftlalbel: false,
                width: "650px",
                height: "570px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick(function (data) {
                        staffTreeCallback(data);
                    });
                }
            });
        });

        //年月下拉初始化
        var date = new Date;
        //年份
        $("#year").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.yearArr && top.clients.yearArr.length) {
                    $.each(top.clients.yearArr, function () {
                        resultObjArr.push({ id: this, text: this });
                    });
                }
                return resultObjArr;
            },
            selectedValue: 1900 + date.getYear(),
        });
        //月份
        $("#month").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.monthArr && top.clients.monthArr.length) {
                    $.each(top.clients.monthArr, function () {
                        resultObjArr.push({ id: this, text: parseInt(this) < 10 ? "0" + this : this });
                    });
                }
                return resultObjArr;
            },
            selectedValue: date.getMonth() + 1,
        });

    }

    //人员树 选择 回调
    function staffTreeCallback(treeSeleData) {

        $('#zls').val(treeSeleData[0].text);
        $('#zlsId').val(treeSeleData[0].id);
        $('#zlsGh').val(treeSeleData[0].value);
    }

    function getUrl() {
        var srcUrl = uri;
        srcUrl = reportServerHOST + srcUrl;
        
        //获取自定义样式
        if (true) {
            if (srcUrl.indexOf('&rc:') == -1) {
                srcUrl += "&rc:Stylesheet=MyStyleSheet";
            }
        }
        if (true) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "orgId=";
            srcUrl += orgId;
        }

        if (false) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "curUserCode=";
            srcUrl += curUserCode;
        }

        if (false) {
            if (srcUrl.indexOf('&rs:') == -1) {
                srcUrl += "&rs:";
            }
            else {
                srcUrl += "&";
            }
            srcUrl += "isHospAdministrator=";
            srcUrl += isHospAdministrator;
        }

        return srcUrl;
    }

</script>
